package OrdersSystem;
import DBSystem.*;

/**
 * 
 * This class contains the attributes, which specify the communication details of each User.
 * 
 * @author iSolutions-Team Orders
 *
 */
public class ContactDetails 
{
	/**
	 * Represents the first part of the User's Address.
	 */
	private String address1;
	/**
	 * Represents the second part of the User's Address.
	 */
	private String address2;
	/**
	 * Represents the third part of the User's Address.
	 */
	private String address3;
	/**
	 * Represents the post code of the User's Address.
	 */
	private String postcode;
	/**
	 * Represents the telephone of the User.
	 */
	private String telephone;
	/**
	 * Represents the email address of the User.
	 */
	private String email;
	
	/**
	 * A Constructor for this class
	 * 
	 * @param address1 first line of address.
	 * @param address2 second line of address.
	 * @param address3 third line of address.
	 * @param postcode specifies the User's address.
	 * @param telephone specifies the User's phone number.
	 * @param email specifies digital contact details.
	 * 
	 */
	public ContactDetails(String address1, String address2, String address3, String postcode,
							String telephone, String email)
	{
		this.address1 = address1;
		this.address2 = address2;
		this.address3 = address3;
		this.postcode = postcode;
		this.telephone = telephone;
		this.email = email;
	}
	
	/**
	 * A Class Constructor, which retrieves the user contact details from the database.
	 * 
	 * @param userID the unique number, which represents each user into the database. 
	 * 
	 */
	public ContactDetails(int userID) { 
		DBSystemComm dbCommunicator = new DBSystemComm(); // connect to database
		ContactDetails contact = dbCommunicator.getContactDetails(userID);
		if(contact != null) {
			this.address1 = contact.getAddress1(); // copy what is stored in the database here
			this.address2 = contact.getAddress2();
			this.address3 = contact.getAddress3();
			this.postcode = contact.getPostcode();
			this.telephone = contact.getTelephone();
			this.email = contact.getEmail();
		}else{
			this.address1 = null;
			this.address2 = null;
			this.address3 = null;
			this.email = null;
			this.postcode = null;
			this.telephone = null;
		}
	}
		
	// Accessors
	
	/**
	 * Gets an attribute.
	 * @return email. 
	*/
	public String getEmail() {
		return email;
	}
	
	/**
	 * Gets an attribute.
	 * @return address1. 
	*/
	public String getAddress1() {
		return address1;
	}
	
	/**
	 * Gets an attribute.
	 * @return address2. 
	*/
	public String getAddress2() {
		return address2;
	}
	
	/**
	 * Gets an attribute.
	 * @return address3. 
	*/
	public String getAddress3() {
		return address3;
	}
	
	/**
	 * Gets an attribute.
	 * @return postcode. 
	*/
	public String getPostcode() {
		return postcode;
	}
	
	/**
	 * Gets an attribute.
	 * @return telephone. 
	*/
	public String getTelephone() {
		return telephone;
	}
	
	// Mutator
	/**
	 * Modifies an attribute.
	 * @param email. 
	*/
	public void setEmail(String email) {
		this.email = email;
	}
	
	/**
	 * Modifies an attribute.
	 * @param address1. 
	*/
	public void setAddress1(String address1) {
		this.address1 = address1;
	}
	
	/**
	 * Modifies an attribute.
	 * @param address2.
	*/
	public void setAddress2(String address2) {
		this.address2 = address2;
	}
	
	/**
	 * Modifies an attribute.
	 * @param address3. 
	*/
	public void setAddress3(String address3) {
		this.address3 = address3;
	}
	
	/**
	 * Modifies an attribute.
	 * @param postcode. 
	*/
	public void setPostcode(String postcode) {
		this.postcode = postcode;
	}

	/**
	 * Modifies an attribute.
	 * @param telephone.
	*/
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

}
